package com.iot.service.mqtt.service.auth.fix;

import com.iot.service.mqtt.config.TlAuthProperties;
import com.iot.service.mqtt.service.auth.AbstractTlAuthentication;
import com.iot.service.mqtt.service.auth.TlUser;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author: hszhou
 * @Date: 2025/5/10 11:54
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
@Service
@RequiredArgsConstructor
@Slf4j
public class FixTlAuthentication extends AbstractTlAuthentication {

    private final TlAuthProperties authProperties;
    @Override
    public boolean authenticate(String username, String password) {
        for (TlUser user : authProperties.getUser()) {
            if (user.getUsername().equals(username) && user.getPassword().equals(password)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean enabled() {
        return true;
    }
}
